#!/bin/bash

export  JAVA_HOME=/opt/apps/jdk1.8.0_191
export  HADOOP_HOME=/opt/apps/hadoop-3.1.1
export  HIVE_HOME=/opt/apps/hive-3.1.2

# 默认日期  T-1
dt=$(date -d'-1 days' +%Y-%m-%d)
if [  $1 ]; then
    dt=$1
fi
echo "正准备入库${dt}日的数据到ODS............"

$HIVE_HOME/bin/hive -e  "load  data  inpath  '/cool/${dt}/appLog' into table ods.cool_app_log partition(dt='${dt}')"   1>/dev/null  2>&1  &
if [ $? -eq 0 ]; then
    echo  "${dt}数据入库成功............"
    echo  "恭喜你: ${dt}数据入库成功!"  | mail -ods  "${dt}入库SUCCESS"  15151515@qq.com
fi




